package com.duoketech.utils;

import com.duoketech.model.activity.Activity;
import com.duoketech.model.activityorder.ActivityOrder;
import com.duoketech.model.order.Order;
import com.jfinal.weixin.sdk.api.TemplateData;
import com.jfinal.weixin.sdk.api.TemplateMsgApi;

import java.util.Date;

public class WxMsgTemplateUtils {

    public static final String BOOKING_SUCCESS_TEMPLATE_ID="jc7FNfDBSNTJERDb3hMnGF-CLNbDJiDy_vilvaNMADE";//活动,酒店预订成功通知
    public static final String ORDER_PAY_SUCCESS_TEMPLATE_ID="HidN76eTcWS8yL1wemMTDX1OnaC-BzHlQ5UIxrj3vew";//商品订单支付成功通知
    public static final String MOBILE_CODE_TEMPLATE_ID="4BuQLm1fs2MQfUVBqe2-QiNyJ2XZPC-v4lz0Eyjd3lQ";// 手机号验证码下发通知
    public static final String ORDER_UNPAY_TEMPLATE_ID="oXTpyKGfSPKW-31ABvAKxNJbymH_WnHsCOxPFswjafc";// 订单未支付通知
    public static final String ROOM_CHECKIN_TEMPLATE_ID="dUZKBprqvt8t9ZvGdIgDgoLiP5Z3ylBDeBk3y7hOoXs";// 预订入住提醒
    public static final String ORDER_CANCEL_TEMPLATE_ID="UjVnSxsAlcTABpJMbtblBccvFoqpNqWYZ5GgRUPsh74";// 订单取消提醒
    public static final String ORDER_READY_SEND_TEMPLATE_ID="l9E-qGKq8A_daka0rgED37zxwSPcXMhAUCvAkyvZU9U";// 订单待发货提醒
    public static final String MEMBER_JOIN_IN_TEMPLATE_ID="ZiRtWICQkNhSiBX_47q4TWY4bdFHbyp2Zqr5fhEYj2g";// 会员加入提醒


    public static void sendMobileCodeMsg(String openId,String nickeName,String code){
        String remarker = "这是一个测试的验证码";
        TemplateData data = TemplateData.New();
        data.setTouser(openId);
        data.setTemplate_id(MOBILE_CODE_TEMPLATE_ID);
        data.add("first",nickeName);
        data.add("number",code);
        data.add("remark",remarker);
        String json = data.build();
        TemplateMsgApi.send(json);
    }


    public static void sendBookSuccessMsg(String openId,String nickeName,String name){
        String remarker = "如有任何问题，欢迎拨打贵宾热线400-933-4988.";
        TemplateData data = TemplateData.New();
        data.setTouser(openId);
        data.setTemplate_id(BOOKING_SUCCESS_TEMPLATE_ID);
        data.add("first","亲爱的"+nickeName);
        data.add("keyword1",name);
        data.add("keyword2",PageUtil.formatDataYYMMDDHHMMSS(new Date()));
        data.add("remark",remarker);
        String json = data.build();
        TemplateMsgApi.send(json);
    }

    public static void sendBookSuccessToOwnerMsg(String openId,String nickeName,String name,String contactor,String mobile){
        String remarker = "有新的活动预订订单来了，请赶紧处理并联系确认，报名者联系方式如下：【"+contactor+"】"+mobile;
        TemplateData data = TemplateData.New();
        data.setTouser(openId);
        data.setTemplate_id(BOOKING_SUCCESS_TEMPLATE_ID);
        data.add("first","亲爱的"+nickeName);
        data.add("keyword1",name);
        data.add("keyword2",PageUtil.formatDataYYMMDDHHMMSS(new Date()));
        data.add("remark",remarker);
        String json = data.build();
        TemplateMsgApi.send(json);
    }

    public static void sendPaySuccessMsg(String openId,String nickeName,ActivityOrder activityOrder){
        String remarker = "如有任何问题，欢迎拨打贵宾热线400-933-4988.";
        TemplateData data = TemplateData.New();
        data.setTouser(openId);
        data.setTemplate_id(ORDER_PAY_SUCCESS_TEMPLATE_ID);
        data.add("first","亲爱的"+nickeName);
        data.add("orderMoneySum","￥1000");
        data.add("orderProductName","奶油巧克力");
        data.add("Remark",remarker);
        String json = data.build();
        TemplateMsgApi.send(json);
    }

    public static void sendMemberJoinMsg(String openId,String nickeName,int memberSer){
        String remarker = "如有任何问题，欢迎拨打贵宾热线400-933-4988.";
        TemplateData data = TemplateData.New();
        data.setTouser(openId);
        data.setTemplate_id(MEMBER_JOIN_IN_TEMPLATE_ID);
        data.add("first","亲爱的"+nickeName);
        data.add("keyword1",memberSer+"");
        data.add("keyword2",PageUtil.formatDataYYMMDDHHMMSS(new Date()));
        data.add("remark",remarker);
        String json = data.build();
        TemplateMsgApi.send(json);
    }

    public static void sendOrderReadyDeleveryMsg(String openId, String nickeName, Order order, String buyer){
        String remarker = "有新的提醒发货申请，请及时去工作台处理";
        TemplateData data = TemplateData.New();
        data.setTouser(openId);
        data.setTemplate_id(ORDER_READY_SEND_TEMPLATE_ID);
        data.add("first","亲爱的"+nickeName);
        data.add("keyword1",order.getStr(Order.ORDER_SER));
        data.add("keyword2","￥"+order.totalFee());
        data.add("keyword3",buyer);
        data.add("keyword4",order.status());
        data.add("remark",remarker);
        String json = data.build();
        TemplateMsgApi.send(json);
    }

    public static void sendOrderUnpayMsg(String openId,String nickeName,ActivityOrder activityOrder){
        String remarker = "还未付款，未付款订单24时内关闭，请及时付款。感谢您对1号店的青睐！点击查看详情。";
        TemplateData data = TemplateData.New();
        data.setTouser(openId);
        data.setTemplate_id(ORDER_UNPAY_TEMPLATE_ID);
        data.add("first","亲爱的"+nickeName);
        data.add("ordertape","3705121411");
        data.add("ordeID","666");
        data.add("remark",remarker);
        String json = data.build();
        TemplateMsgApi.send(json);
    }


    public static void sendOrderCancelMsg(String openId,String nickeName,String eventContent,String orderId){
        String remarker = "如果您有什么不满意的，请赶紧联系我们";
        TemplateData data = TemplateData.New();
        data.setTouser(openId);
        data.setTemplate_id(ORDER_CANCEL_TEMPLATE_ID);
        data.add("first","亲爱的"+nickeName);
        data.add("keyword1",orderId);
        data.add("keyword2","【取消预订】"+eventContent);
        data.add("remark",remarker);
        String json = data.build();
        TemplateMsgApi.send(json);
    }

    public static void sendOrderCancelToOwnerMsg(String openId,String nickeName,String eventContent,String orderId,String contactor,String mobile){
        String remarker = "用户取消了预订，请及时处理，联系人信息如下：【"+contactor+"】"+mobile;
        TemplateData data = TemplateData.New();
        data.setTouser(openId);
        data.setTemplate_id(ORDER_CANCEL_TEMPLATE_ID);
        data.add("first","亲爱的"+nickeName);
        data.add("keyword1",orderId);
        data.add("keyword2","【取消预订】"+eventContent);
        data.add("remark",remarker);
        String json = data.build();
        TemplateMsgApi.send(json);
    }

    public static void sendRoomCheckInMsg(String openId,String nickeName,String name,String startTime,String endTime){
        String remarker = "感谢你的预订，我们将竭尽全力的为你提供优质的服务。";
        TemplateData data = TemplateData.New();
        data.setTouser(openId);
        data.setTemplate_id(ROOM_CHECKIN_TEMPLATE_ID);
        data.add("first","亲爱的"+nickeName);
        data.add("keyword1",name);
        data.add("keyword2",startTime);
        data.add("keyword3",endTime);
        data.add("remark",remarker);
        String json = data.build();
        TemplateMsgApi.send(json);
    }

    public static void sendRoomCheckInToOwnerMsg(String openId,String nickeName,String name,
                                                 String startTime,String endTime,String contactor,String mobile){
        String remarker = "有新的客栈预订订单来了，请赶紧处理并联系确认，预订者联系方式如下：【"+contactor+"】"+mobile;
        TemplateData data = TemplateData.New();
        data.setTouser(openId);
        data.setTemplate_id(ROOM_CHECKIN_TEMPLATE_ID);
        data.add("first","亲爱的"+nickeName);
        data.add("keyword1",name);
        data.add("keyword2",startTime);
        data.add("keyword3",endTime);
        data.add("remark",remarker);
        String json = data.build();
        TemplateMsgApi.send(json);
    }


}
